package com.imooc.dao;

import com.imooc.bean.Command;
import com.imooc.bean.Message;
import com.imooc.db.DBAccess;
import org.apache.ibatis.session.SqlSession;

import java.io.IOException;
import java.util.List;

public class CommandDao {

    public List<Command> queryCommandList(String name, String description) {
        DBAccess dbAccess = new DBAccess();
        SqlSession session = null;
        List<Command> commandList = null;
        try {
            session = dbAccess.getSqlSession();
            Command command = new Command();
            command.setName(name);
            command.setDescription(description);
            commandList = session.selectList("Command.queryCommandList", command);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (session != null)
                session.close();
        }
        return commandList;
    }
}
